﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel;
using WCFSample.Contracts;

namespace WCFSample.Web
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            using (ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>("CalculatorServiceTcp"))
            {
                ICalculator proxy = channelFactory.CreateChannel();
                using (proxy as IDisposable)
                {
                    double x = double.Parse(this.txtX.Text);
                    double y = double.Parse(this.txtY.Text);
                    this.lblResult.Text = proxy.Add(x, y).ToString();
                }
            }
        }
    }
}
